#include <bits/stdc++.h>
#include <cstring>
#include <sstream>
#define ll long long int
#define pb() push_back()
#define f(i,n) for(i=0;i<n;i++)
#define cin(n) scanf("%lld",&n)
#define cout(n) printf("%lld",n)
using namespace std;
ll prime(ll n)
{
ll i;
if(n==2)
return 1;
else if(n%2==0)
return 0;
else{
for(i=3;i*i<=n;i+=2){
if(n%i==0)
return 0;
}
}
return 1;
}
ll fun(ll n)
{
ll x=0;
while(n){
x+=n%10;
n=n/10;
}
return x;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t,a,b,c,d,i,j,k,l,n,m,x,y,z;
cin>>t;
while(t--){
cin>>n>>k;
ll s[n+5];
map<ll,ll>h;
for(i=1;i<=n;i++)
cin>>s[i];
while(k--){
cin>>a;
if(a==1){
cin>>b>>c;
y=0;
for(j=b;j<=c;j++){
if(h[j]<11)
h[j]++;
else{
y=j;
break;
}
}
if(y){
for(i=c;i>y;i--){
if(h[i]<11)
h[i]++;
else
break;
}
}
}
else{
cin>>z;
d=h[z];
l=s[z];
while(d--){
l=fun(l);
}
cout<<l<<endl;
}
}
}
}
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |